package com.hpe.aruba.CPPM.objects;

import java.util.Calendar;

public class Token {
    private String token;
    private long expiration;

    public Token(String type, String token, int expiration) {
        this.token = type + " " + token;
        Calendar calendar = Calendar.getInstance(); // gets a calendar using the default time zone and locale.
        calendar.add(Calendar.SECOND, expiration);
        this.expiration = calendar.getTimeInMillis();
        System.out.println(calendar.getTime());
    }

    public Token() {
    }

    public String getToken() {
        return token;
    }

    public void setToken(String token) {
        this.token = token;
    }

    public long getExpiration() {
        return expiration;
    }

    public void setExpiration(long expiration) {
        this.expiration = expiration;
    }

    public boolean isTokenValid() {
        Calendar calendar = Calendar.getInstance();
        return calendar.getTimeInMillis() < expiration;
    }
}
